package com.lanniao.controller;

import com.lanniao.entity.Dept;
import com.lanniao.entity.TbUser;
import com.lanniao.result.Result;
import com.lanniao.service.DeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("dept")
@Api(tags = "部门相关接口")
public class DeptControllrt {

    @Autowired
    private DeptService deptService;

    @GetMapping("/{id}")
    @ApiOperation("根据id获取部门信息")
    public Result getById(@PathVariable Integer id){
        Dept dept = deptService.getById(id);
        return Result.success(dept);
    }

    @GetMapping("/list/{deptId}")
    @ApiOperation("根据部门id查询用户信息")
    public Result getUserById(@PathVariable Integer deptId){
        List<TbUser> tbUserList = deptService.getUserById(deptId);
        return Result.success(tbUserList);
    }

}
